home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-reatim.ads < prev    next >
Text File  |  1996-01-30  |  4KB  |  113 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                          A D A . R E A L _ T I M E                       --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.15 $                             --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18.  
  19. with System.Task_Clock;
  20. --  Used for, Stimespec and associated constants
  21.  
  22. with System.Task_Clock.Machine_Specifics;
  23. --  Used for, Stimespec_Ticks
  24.  
  25. with System.Tasking;
  26. --  Used for, Protection
  27.  
  28. package Ada.Real_Time is
  29.  
  30.    type Time is private;
  31.    Time_First : constant Time;
  32.    Time_Last  : constant Time;
  33.    Time_Unit  : constant := 10#1.0#E-9;
  34.  
  35.    type Time_Span is private;
  36.    Time_Span_First : constant Time_Span;
  37.    Time_Span_Last  :  constant Time_Span;
  38.    Time_Span_Zero  :  constant Time_Span;
  39.    Time_Span_Unit  :  constant Time_Span;
  40.  
  41.    Tick : constant Time_Span;
  42.    function Clock return Time;
  43.  
  44.    function "+"  (Left : Time;      Right : Time_Span) return Time;
  45.    function "+"  (Left : Time_Span; Right : Time)      return Time;
  46.    function "-"  (Left : Time;      Right : Time_Span) return Time;
  47.    function "-"  (Left : Time;      Right : Time)      return Time_Span;
  48.  
  49.    function "<"  (Left, Right : Time) return Boolean;
  50.    function "<=" (Left, Right : Time) return Boolean;
  51.    function ">"  (Left, Right : Time) return Boolean;
  52.    function ">=" (Left, Right : Time) return Boolean;
  53.  
  54.    function "+"  (Left, Right : Time_Span)             return Time_Span;
  55.    function "-"  (Left, Right : Time_Span)             return Time_Span;
  56.    function "-"  (Right : Time_Span)                   return Time_Span;
  57.    function "*"  (Left : Time_Span; Right : Integer)   return Time_Span;
  58.    function "*"  (Left : Integer;   Right : Time_Span) return Time_Span;
  59.    function "/"  (Left, Right : Time_Span)             return Integer;
  60.    function "/"  (Left : Time_Span; Right : Integer)   return Time_Span;
  61.  
  62.    function "abs" (Right : Time_Span) return Time_Span;
  63.  
  64.    function "<"  (Left, Right : Time_Span) return Boolean;
  65.    function "<=" (Left, Right : Time_Span) return Boolean;
  66.    function ">"  (Left, Right : Time_Span) return Boolean;
  67.    function ">=" (Left, Right : Time_Span) return Boolean;
  68.  
  69.    function To_Duration  (FD : Time_Span) return Duration;
  70.    function To_Time_Span (D : Duration)   return Time_Span;
  71.  
  72.    function Nanoseconds  (NS : integer) return Time_Span;
  73.    function Microseconds (US : integer) return Time_Span;
  74.    function Milliseconds (MS : integer) return Time_Span;
  75.  
  76.    type Seconds_Count is new integer range -integer'Last .. integer'Last;
  77.  
  78.    procedure Split
  79.      (T : Time;
  80.       S : out Seconds_Count;
  81.       D : out Time_Span);
  82.  
  83.    function Time_Of
  84.      (S    : Seconds_Count;
  85.       D    : Time_Span)
  86.       return Time;
  87.  
  88. private
  89.    type Time is new Task_Clock.Stimespec;
  90.  
  91.    Time_First : constant Time := Time (Task_Clock.Stimespec_First);
  92.  
  93.    Time_Last :  constant Time := Time (Task_Clock.Stimespec_Last);
  94.  
  95.    type Time_Span is new Task_Clock.Stimespec;
  96.  
  97.    Time_Span_First : constant Time_Span :=
  98.      Time_Span (Task_Clock.Stimespec_First);
  99.  
  100.    Time_Span_Last :  constant Time_Span :=
  101.      Time_Span (Task_Clock.Stimespec_Last);
  102.  
  103.    Time_Span_Zero :  constant Time_Span :=
  104.      Time_Span (Task_Clock.Stimespec_Zero);
  105.  
  106.    Time_Span_Unit :  constant Time_Span :=
  107.      Time_Span (Task_Clock.Stimespec_Unit);
  108.  
  109.    Tick :           constant Time_Span :=
  110.      Time_Span (Task_Clock.Machine_Specifics.Stimespec_Ticks);
  111.  
  112. end Ada.Real_Time;
  113.